#!/usr/bin/env python

import sys, os
import urllib
import urllib2

import os3.utils.simplejson as json


class HTTPRPC ( object ):
	def __init__ ( self ):
		super ( HTTPRPC, self ).__init__ ()


	def request ( self, url, dct ):
		data = urllib.urlencode ( dct )
		req = urllib2.Request ( url, data )
		response = urllib2.urlopen ( req )
		res = response.read ()
		res = res.strip ()
		res = res [ 20 : -1 ]

		print res

		res = json.loads ( res )

		return res


if __name__ == '__main__':
	h = HTTPRPC ()
	print h.request ( "http://test_pyhp.os3.lan/ajax.pyhp", { "action": "tags.user.list" } )

